#ifndef _H_SWITCH
#define _H_SWITCH

#include "define.h"
#define SW_SWITCH_NUM 4 

#define P_SW_X00_PORT GPIOA
#define P_SW_X00_PIN 0

#define P_SW_X01_PORT GPIOB
#define P_SW_X01_PIN 5
	 
#define P_SW_X02_PORT GPIOB
#define P_SW_X02_PIN 8

#define P_SW_X03_PORT GPIOB
#define P_SW_X03_PIN 9


#define SW_OFFSET_ENTERCONFIG 0
#define SW_OFFSET_ADD 2
#define SW_OFFSET_DEC 3
#define SW_OFFSET_EXITCONFIG 1


#define SW_KEY_PRESS(var) ((g_sw_stRegs.m_uchLevel[var]) && (g_sw_stRegs.m_uchTrigger[var]))

//------------------------------------------------//

typedef struct{
  U8 m_uchLevel[SW_SWITCH_NUM];
  U8 m_uchTrigger[SW_SWITCH_NUM];
	U8 m_uchCount[SW_SWITCH_NUM];
	U8 m_uchReady;
	U16 m_uiReadyTimer;
	U8 m_uchEvent[SW_SWITCH_NUM];
}SWStatusType;

typedef struct{
	GPIO_TypeDef *port;
	U8 pin;
	U8 debounce;
	U8 level;
}STRSWConfig;

extern SWStatusType g_sw_stRegs;
extern void fnSW_Init(void);
extern void fnSW_RealTime(void);
extern void fnSW_Clear(void);
#endif
